Add support for creating API tokens backed by KMS signer (WIP)#1399
Open
Add support for creating API tokens backed by KMS signer (WIP)#1399
Conversation
azazeal
previously approved these changes
Mar 27, 2025
4f46e13 to
064866f
Compare
52d9a4b to
cd18588
Compare
a71ac72 to
8a7cd1b
Compare
39ea27c to
e53225b
Compare
maraino
requested changes
Apr 1, 2025
Collaborator
maraino
left a comment
There was a problem hiding this comment.
Just a couple of minor things
Collaborator
There was a problem hiding this comment.
Can we add a test that compares this with the one in the standard library?
| func createClientCertificate(crtFile, keyFile, passwordFile, tpmDevice string) (*tls.Certificate, error) { | ||
| certs, err := pemutil.ReadCertificateBundle(crtFile) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed reading %q: %w", crtFile, err) |
Collaborator
There was a problem hiding this comment.
Pemutil already returns a wrapped error, if we wrap it again, we will get:
failed reading "foo.crt": error parsing foo.crt: open foo.crt: no such file or directory
If we want a nicer message, we can fix crypto or use something like:
func maybeUnwrap(err error) error {
if wrapped := errors.Unwrap(err); wrapped != nil {
return wrapped
}
return err
}| // options, such as specifying the TPM device that backs the TSS2 | ||
| // signer. | ||
| p, _ := pem.Decode(b) | ||
| if p.Type != "TSS2 PRIVATE KEY" { |
Collaborator
There was a problem hiding this comment.
I've just added this smallstep/crypto#743 to avoid this condition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR:
--password-fileflag.User-AgentandX-Request-IdHTTP request headers.Using an ECDSA key:
Using an RSA key:
Using the TSS2 PEM encoded private key (exported using
step tpm key get 'test-rsa' --device '/path/to/tpmsimulator.sock' --storage-directory /path/to/tpmstorage --tss2 > tpmrsa.tss2.pem), specified as atpmkmsURI:Using the same TSS2 PEM encoded private key directly:
Note that the
deviceandtpm-deviceflags and URI parts can be omitted in case the default system TPM locations are to be used. The use of a TPM simulator is just for demonstration and testing purposes.